<template lang="pug">
	.get-with-card-wrap
		.top-tip
			top-tip( tip="请填写新生儿出生证明上面的，父亲或母亲的姓名、身份证信息")
		.card-input-container
			input-line(leftText='父(母)姓名' placeholder="请输入父亲或母亲的姓名" type="text" @getValue="getParentName")
			input-line(leftText='身份证号' placeholder="请输入对应的身份证号码" type="idcard" @getValue="getIdNumber" maxlength="18")
		.card-input-container
			input-line(leftText='新生儿姓名' placeholder="请输入新生儿的姓名" type="text" @getValue="getBabyName")
			input-line(leftText='就诊手机号' placeholder="用于接收就诊短信，请认真填写" type="number" @getValue="getPhone" maxlength="11")
		.card-btn(@click="jumpToNext")
			main-button(text="确认提交" :isActive="nextStepPass")
		.no-certificate(@click="noCertificate") 没有出生证明？
</template>

<script>
import inputLine from '@/components/input-line'
import mainButton from '@/components/main-button'
import topTip from '@/components/top-tip'
export default {
	name: 'getWithoutId',
	data() {
		return {
			parentName: '',
			idNumber: '',
			babyName: '',
			phone: '',
			nextStepPassParentName: false,
			nextStepPassIdNumber: false,
			nextStepPassBabyName: false,
			nextStepPassPhone: false
		}
	},
	computed: {
		nextStepPass() {
			return (
				this.nextStepPassParentName &&
				this.nextStepPassIdNumber &&
				this.nextStepPassBabyName &&
				this.nextStepPassPhone
			)
		}
	},
	created() {},
	mounted() {},
	methods: {
		jumpToNext() {
			if (this.nextStepPass) {
				this.submit()
			}
		},
		getParentName(text) {
			text = text.toString()
			this.parentName = text
			this.nextStepPassParentName = text.length > 0
		},
		getIdNumber(text) {
			text = text.toString()
			this.idNumber = text
			if (text.length === 15 || text.length === 18) {
				this.nextStepPassIdNumber = this.tools.identityCodeValid(text)
			} else {
				this.nextStepPassIdNumber = false
			}
		},
		getBabyName(text) {
			text = text.toString()
			this.babyName = text
			this.nextStepPassBabyName = text.length > 0
		},
		getPhone(text) {
			text = text.toString()
			this.phone = text
			if (text.length === 11) {
				this.nextStepPassPhone = this.tools.isMobile(text)
			} else {
				this.nextStepPassPhone = false
			}
		},
		submit() {
			//确认提交
			this.wx.showLoading({
				title: '加载中'
			})
		},
		noCertificate() {
			this.$router.push({
				path: '/views/healthCard/getWithoutCertificate'
			})
		}
	},
	components: {
		topTip,
		inputLine,
		mainButton
	}
}
</script>

<style lang="stylus">
	.get-with-card-wrap
		.top-tip
			padding mainPadding
		.card-input-container
			margin-bottom mainMargin
			background-color white
			.input-line-wrap
				margin 0
				padding 0 40px
				&:last-child
					border-bottom-color transparent
		.card-btn
			width 690px
			height 92px
			margin 60px auto 0
			border-radius 46px
			overflow hidden
	.no-certificate
		margin-top 30px
		text-align center
		font-size 26px
		line-height 36px
		color themeColor
</style>
